package cn.mzcode.xyzpfuwuduan.controller;


import cn.mzcode.xyzpfuwuduan.common.ServerResponse;
import cn.mzcode.xyzpfuwuduan.pojo.Company;
import cn.mzcode.xyzpfuwuduan.pojo.Position;
import cn.mzcode.xyzpfuwuduan.service.ICompanyService;
import cn.mzcode.xyzpfuwuduan.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageInfo;


@Controller
@RequestMapping("/company/")
public class CompanyController {

    @Autowired
    private ICompanyService iCompanyService;


    /**
     * 添加或更新公司信息
     * @param company
     * @return
     */
    @RequestMapping("save_Or_Update.do")
    @ResponseBody
    public ServerResponse companySaveOrUpdate(Company company) {
       return iCompanyService.saveOrUpdateCompany(company);
    }

    /**
     * 搜索公司信息(如有条件按条件查询，如没有条件则列出所有公司及其详细信息)
     * @param company
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("select.do")
    @ResponseBody
    public ServerResponse<PageInfo> select(Company company ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                           @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iCompanyService.selectCompany(company, pageNum, pageSize);
    }
}
